package com.monkeyk.os.service.util;

import com.taobao.api.ApiException;
import com.taobao.api.DefaultTaobaoClient;
import com.taobao.api.TaobaoClient;
import com.taobao.api.request.AlibabaAliqinFcSmsNumSendRequest;
import com.taobao.api.response.AlibabaAliqinFcSmsNumSendResponse;

    /**
    * @Author mountain
    * @date 2017/3/7 17:22
    * @for
    * @params
    * @return
    */
public abstract class SmsUtils {

    public static String SendMessage(String code, String phone, String type) throws ApiException {
        String url = "http://gw.api.taobao.com/router/rest";
        String appkey = "23669025";
        String secret = "b1ff08efbc9325f8ab2ecdd13952be46";

        TaobaoClient client = new DefaultTaobaoClient(url, appkey, secret);
        AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();
        req.setExtend("");
        req.setSmsType("normal");
        req.setSmsFreeSignName(type);
        req.setSmsParamString("{code:'" + code + "',minute:'"+10+"'}");
        req.setRecNum(phone);
        req.setSmsTemplateCode("SMS_52425282");
        AlibabaAliqinFcSmsNumSendResponse rsp = client.execute(req);
        System.out.println(rsp.getBody());
        return rsp.getBody();
    }

    public static void main(String[] args) throws ApiException {
        String result = SmsUtils.SendMessage("123456", "15827526384", "海印物业");
    }
}
